> ## Documentation Index
> Fetch the complete documentation index at: https://edimez14-password_generator.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Saved Password

Saves a password for a specific URL or page. Requires authentication.

## Endpoint

```
POST /api/password-generator/save-passwords/
```

## Authentication

**Authorization** `string` *required*

Bearer token for authentication. User must be logged in.

## Request Body

**user** `integer` *required*

The user ID who is saving the password.

**password\_saved** `string` *required*

The password to be saved (max 200 characters).

**url** `string` *required*

The URL where this password is used (max 200 characters).

**name\_pages** `string`

A friendly name for the page or service (max 200 characters).

### Request Example

```json theme={null}
{
  "user": 1,
  "password_saved": "MySecureP@ss123",
  "url": "https://example.com",
  "name_pages": "Example Website"
}
```

## Response

### Success Response

```json 200 OK theme={null}
"password saved successfully"
```

### Error Responses

```json 400 Bad Request theme={null}
{
  "user": ["This field is required."],
  "password_saved": ["This field is required."],
  "url": ["This field is required."]
}
```

```json 400 Bad Request theme={null}
{
  "error": "Missing required fields."
}
```

```json 404 Not Found theme={null}
{
  "error": "password does not exist after creation."
}
```

```json 500 Internal Server Error theme={null}
{
  "error": "error message"
}
```

## Example Request

```bash cURL theme={null}
curl -X POST https://api.example.com/api/password-generator/save-passwords/ \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "user": 1,
    "password_saved": "MySecureP@ss123",
    "url": "https://example.com",
    "name_pages": "Example Website"
  }'
```

```javascript JavaScript theme={null}
fetch('https://api.example.com/api/password-generator/save-passwords/', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    user: 1,
    password_saved: 'MySecureP@ss123',
    url: 'https://example.com',
    name_pages: 'Example Website'
  })
})
.then(response => response.json())
.then(data => console.log(data));
```

```python Python theme={null}
import requests

headers = {
    'Authorization': 'Bearer YOUR_TOKEN',
    'Content-Type': 'application/json'
}

data = {
    'user': 1,
    'password_saved': 'MySecureP@ss123',
    'url': 'https://example.com',
    'name_pages': 'Example Website'
}

response = requests.post(
    'https://api.example.com/api/password-generator/save-passwords/',
    headers=headers,
    json=data
)
print(response.json())
```

## Implementation Details

This endpoint is implemented in `views.py:32` using the `save_passwords` view function. It validates the request data using `SavedPasswordsSerializer` and saves the password to the database associated with the authenticated user.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.